﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GoodTrader.GTDownload
{
    public class CpDownLoader
    {
        public CpDownLoader(CpDownLoadManager aDownManager)
        {
            mDownManager = aDownManager;
        }

        protected int mCurIndex = 0;
        public int CurIndex
        {
            get { return mCurIndex; }
            set { mCurIndex = value; }
        }

        private bool mEnable = true;
        public bool Enable
        {
            get { return mEnable; }
            set { mEnable = value; }
        }
        protected CPUTILLib.CpFutureCode m_CpFutureCode = new CPUTILLib.CpFutureCode();

        private CpDownLoadManager mDownManager = null;
        public CpDownLoadManager DownManager
        {
            get { return mDownManager; }
            set { mDownManager = value; }
        }
        public virtual void Download()
        {
            if (mDownManager == null)
            {
                return;
            }
            // 이벤트를 리셋시켜 쓰레드가 더이상 실행되는 것을 막는다. 
            mDownManager.Event.Reset();
            //System.Windows.Forms.MessageBox.Show("BaseReset");
        }

        public virtual void OnReceived()
        {
            if (mDownManager == null)
            {
                return;
            }
            // 다운이 완료되면 다음 객체가 다운을 받을 수 있도록 이벤트를 설정한다.
            mDownManager.Event.Set();
            //System.Windows.Forms.MessageBox.Show("BaseSet");
        }
    }
}
